<script>
import {defineComponent} from 'vue'

export default defineComponent({
  name: "NavList",
  data() {
    return {
      currentIndex: 0,
    }
  },
  emits:["changeShowCom"],
  props:{
    navTitleData:{
      type:Array,
      required:true
    }
  },
  methods: {
    clickHandler(index) {
      this.currentIndex = index
      this.$emit("changeShowCom",index)
    }
  }
})
</script>

<template>
  <ul>
    <li v-for="(item,index) in navTitleData" @click="clickHandler(index)" :class="{active:currentIndex===index}">{{ item }}</li>
  </ul>
</template>

<style scoped lang="less">
ul {
  width: 100%;
  height: 50px;
  background-color: #ccc;
  color: #000;
  display: flex;
  justify-content: space-around;
  align-items: center;
  li {
    cursor: pointer;
    height: 100%;
    display: flex;
    align-items: center;
    list-style: none;
  }
  .active{
    color: #fa1313;
    border-bottom: 3px solid #fa1313;
  }
}
</style>
